package org.judo.generate.mvc;

import org.judo.util.Util;

public class ActionCodeParser implements Parser
{
	ActionCodeResult actionResult;
	ParseResults parseResults;
	String curStatement;
	Parser nextParser;
	ActionCodeContainer container;
	
	public ActionCodeContainer getContainer()
	{
		return container;
	}

	public void setContainer(ActionCodeContainer container)
	{
		this.container = container;
	}

	public ParseResults getParseResults()
	{
		return parseResults;
	}

	public void setParseResults(ParseResults parseResults)
	{
		this.parseResults = parseResults;
	}
	
	public Parser getNestedParser()
	{
		return nextParser;
	}

	public boolean isFinished()
	{
		if (curStatement != null)
			if (curStatement.equals("/action"))
			{
				return true;
			}
				
		return false;
	}

	public boolean needsNestedParser()
	{
		if (nextParser != null)
			return true;
		
		return false;
	}

	public void parseNextLine(String line) throws ParseException
	{
		nextParser = null;
		curStatement = line;
		
		if (line.startsWith("/action"))
		{
		}
		else
		{
			actionResult.javaCode += "\t\t"+line+"\n";
		}
	}

	public void setInitLine(String line) throws ParseException
	{
		actionResult = new ActionCodeResult();
		container.actionCode = actionResult;
	}
}

